package com.yanqu.road.server.channelserver.cmd.activity.washepk;

import com.yanqu.road.entity.activity.area.wase.ChannelWashePkUserData;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.cross3.activity.AreaWashePkProto;
import com.yanqu.road.server.channelserver.cmd.ChannelCommand;
import com.yanqu.road.server.channelserver.logic.ChannelMessageHelper;
import com.yanqu.road.server.channelserver.manager.activity.washepk.ChannelWashPkActivity;
import com.yanqu.road.server.channelserver.manager.activity.washepk.ChannelWashePkMgr;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.N_AREA_WASHE_PK_DATA_GET, desc = "")
public class ChannelWashePkGetUserDataCmd extends ChannelCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

        AreaWashePkProto.ChannelAreaWashePkGetUserDataReq req = AreaWashePkProto.ChannelAreaWashePkGetUserDataReq.parseFrom(packet.getBytes());
        int activityId = req.getActivityId();
        ChannelWashPkActivity activity = ChannelWashePkMgr.getActivity(activityId);
        if(activity != null){
            ChannelWashePkUserData userData = activity.getChannelUserData(req.getUserKey().getUserId(), PlayerBasePb.parseToUserBaseInfo(req.getUserBaseInfo()));
            if(userData != null){
                AreaWashePkProto.AreaWashePkGetUserDataResp.Builder clientMsg = ChannelWashePkMgr.getUserBuilder(userData);
                ChannelMessageHelper.sendGamePacket(Protocol.U_AREA_WASHE_PK_DATA_GET, clientMsg, req.getUserKey().getChannelId(), req.getUserKey().getServerId(),
                        req.getUserKey().getUserId());
            }
        }
    }


    @Override
    public void sendData() {

    }
}
